//package io.wilson.rabbit.config;
//
//import io.wilson.rabbit.common.constant.RabbitMQConstant;
//import io.wilson.rabbit.common.constant.SpringContextUtils;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.amqp.core.*;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//import javax.annotation.PostConstruct;
//import javax.annotation.Resource;
//
///**
// * Topic：主题型
// * - RoutingKey可标识*(匹配.后一个单词的Topic)、.#(匹配多个词)通配符绑定队列。例：
// *   - a.*：能够匹配a.b、a.c、a.xxx队列让这些队列消费消息，但不能匹配a.a.a、a.b.c
// *   - a.item：
// * - 当发送消息时，会通过发送消息的RoutingKey与对应Exchange绑定队列的RoutingKey
// * 进行匹配，匹配到的队列都会消费消息。发送端或接收端的RoutingKey都可设置通配符，匹配上的队列都会消费
// */
//@Slf4j
//@Configuration
//public class TopicConfig {
//    @Resource
//    private SpringContextUtils springContextUtils;
//
///*
//    @PostConstruct
//    public void init() {
//        Exchange exchange = new DirectExchange(RabbitMQConstant.SEQUENCE_DIRECT_EXCHANGE);
//        springContextUtils.registerSingletonBean(RabbitMQConstant.SEQUENCE_DIRECT_EXCHANGE, new DirectExchange(RabbitMQConstant.DIRECT_EXCHANGE_NAME));
//        for (int i = 0; i < 10; i++) {
//            String queue = RabbitMQConstant.SEQUENCE_DIRECT_QUEUE + i;
//            springContextUtils.registerSingletonBean(queue, new Queue(queue));
//            springContextUtils.registerSingletonBean("binding-" + i,
//                    BindingBuilder.bind(springContextUtils.getBean(queue, Queue.class))
//                            .to(exchange).with("sequence-routing-" + i));
//        }
//        log.info("topic routing init completed");
//    }
//*/
//
//    @Bean
//    public TopicExchange topicExchange() {
//        return new TopicExchange(RabbitMQConstant.TOPIC_EXCHANGE_NAME);
//    }
//
//    @Bean
//    public Queue topicQueueA() {
//        return new Queue(RabbitMQConstant.TOPIC_QUEUE_NAME_1);
//    }
//
//    @Bean
//    public Queue topicQueueB() {
//        return new Queue(RabbitMQConstant.TOPIC_QUEUE_NAME_2);
//    }
//
//    @Bean
//    public Queue topicQueueC() {
//        return new Queue(RabbitMQConstant.TOPIC_QUEUE_NAME_3);
//    }
//
//    @Bean
//    public Binding topicBindingA(Queue topicQueueA, TopicExchange topicExchange) {
//        return BindingBuilder.bind(topicQueueA)
//                .to(topicExchange).with(RabbitMQConstant.TOPIC_ROUTING_KEY_A);
//    }
//
//    @Bean
//    public Binding topicBindingB(Queue topicQueueB, TopicExchange topicExchange) {
//        return BindingBuilder.bind(topicQueueB)
//                .to(topicExchange).with(RabbitMQConstant.TOPIC_ROUTING_ONE_PATTERN);
//    }
//
//    @Bean
//    public Binding topicBindingC(Queue topicQueueC, TopicExchange topicExchange) {
//        return BindingBuilder.bind(topicQueueC)
//                .to(topicExchange).with(RabbitMQConstant.TOPIC_ROUTING_MORE_PATTERN);
//    }
//}
